package turing.forum.web.vo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import turing.forum.repository.po.UserShare;

import java.util.Date;

@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class UserShareVo {
    private Long id;
    private Long userId;
    private String content;
    private String[] pictures;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    public UserShareVo(UserShare share) {
        this.id = share.getId();
        this.userId = share.getUserId();
        this.content = share.getContent();
        this.createTime = share.getCreateTime();
        String pictures = share.getPictures();
        if (pictures == null || "".equals(pictures)) {
            this.pictures = null;
        } else {
            this.pictures = pictures.split("\n");
        }
    }
}
